<div class="span3" id="user-role-add-block">
	<h4 class="title"><?php echo t('page', 'Add User Role'); ?></h4>
	<div class="squiggly-border"></div>
	<div class="row-fluid">
		<div class="span12 add_user_role_form_info hide" id="add_user_role_success_info">
			<div class="alert alter-block alert-success">
	<!--			<button type="button" class="close" data-dismiss="alert">&times;</button>-->
				<h4>Success</h4>
				<div class="content">New user role has added!</div>
			</div>
		</div>
	</div>
	
	<div class="row-fluid">
		<div class="span12 add_user_role_form_info hide" id="add_user_role_error_info">
			<div class="alert alter-block alert-error">
	<!--			<button type="button" class="close" data-dismiss="alert">&times;</button>-->
				<h4>Error</h4>
				<div class="content"></div>
			</div>
		</div>
	</div>
	
	<?php $form = $this->beginWidget('CActiveForm', array(
		'id' => 'role-add-form',
		'enableClientValidation' => true,
		'clientOptions' => array(
			'validateOnSubmit' => true,
		),
	)); ?>
	
		<div class="row-fluid">
			<?php echo $form->textField($userRoleAddForm, 'name', array('placeholder' => $userRoleAddForm->getFieldLabel('name'), 'class' => 'fields')); ?>
		</div>
	
		<div class="row-fluid">
			<?php echo $form->textArea($userRoleAddForm, 'description', array('placeholder' => $userRoleAddForm->getFieldLabel('description'), 'class' => 'fields')); ?>
		</div>
	
		<div class="row-fluid buttons">
			<?php echo CHtml::ajaxSubmitButton(
				t('buttons', 'Add User Role'), 
				app()->createUrl('user/role'),
				array(
					'type' => 'post',
					'beforeSend' => 'function(){
						$("#add_user_role_submit").button("loading");
					}',
					'success' => 'function(ret){
						$(".add_user_role_form_info").hide();
						if(ret["result"]){
							$("#add_user_role_success_info").blink({
								"beforeCall": function(){
									var tr = $("<tr />");
									tr.append( $("<td class=\"hide id_user_role\" />").html(ret["detail"]["id_user_role"]) );
									tr.append( $("<td class=\"name\" />").html(ret["detail"]["name"]) );
									tr.append( $("<td class=\"description\" />").html(ret["detail"]["description"]) );
									tr.append( $("<td />").html('.json_encode(UserRole::renderListActionButtons()).') );
									
									$("#user_role_grid table").prepend(tr);
									$("form#role-add-form .fields").val("");
								}
							});
						}else{
							$("#add_user_role_error_info").blink({
								"beforeCall": function(){
									$("#add_user_role_error_info .content").html("");
									$.each(ret["errors"], function(attrName, error){
										$(error).each(function(k, e){
											var p = $("<p />").addClass("text-error").append(attrName+": "+e);
											$("#add_user_role_error_info .content").append(p);
										});
									});
								}
							});
						}
						
						$("#add_user_role_submit").button("reset");
					}',
					'dataType' => 'json'
				),
				array(
					'id' => 'add_user_role_submit',
					'type' => 'button', 
					'class' => 'btn btn-small btn-primary',
					'data-loading-text' => t('buttons', 'Saving...')
				)
			); ?>
		</div>
	
	<?php $this->endWidget(); ?>
</div>